package com.jingdong.controller;

import com.jingdong.model.Product_type_one;
import com.jingdong.model.Product_type_three;
import com.jingdong.model.Product_type_two;
import com.jingdong.service.productType.ProductTypeOneService;
import com.jingdong.service.productType.ProductTypeThreeService;
import com.jingdong.service.productType.ProductTypeTwoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.jws.Oneway;
import java.util.List;

@Controller
@RequestMapping("productTotalList")
public class ProductTypeListController {
    @Autowired
    private ProductTypeOneService typeOneService;
    @Autowired
    private ProductTypeTwoService typeTwoService;
    @Autowired
    private ProductTypeThreeService typeThreeService;
    @RequestMapping("productTypeList")
    public ModelAndView productTypeList() {
        ModelAndView mav = new ModelAndView("/home/productTotalList");
        List<Product_type_one> typeOneList = typeOneService.oneTypeList();
        mav.addObject("typeOneList", typeOneList);
        return mav;
    }

    @RequestMapping("productTwoTypeList")
    public @ResponseBody
    Object twoTypeList(Integer oneTypeId) {
        List<Product_type_two> type_twoList = typeTwoService.twoTypeList(oneTypeId);
        return type_twoList;
    }
    @RequestMapping("productThreeTypeList")
    public @ResponseBody Object threeTypeList(Integer twoTypeId){
        List<Product_type_three> type_threeList=typeThreeService.threeTypeList(twoTypeId);
        return type_threeList;
    }
}
